package org.geektimes.projects.user.web.listener;
import org.geektimes.projects.user.sql.DBConnectionManager;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DerbyTest {
    public static void main(String[] args) throws Exception{
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        Connection connection = DriverManager.getConnection("jdbc:derby:/db/user-platform;create=true");
        new DBConnectionManager().setConnection(connection);
        Statement statement = connection.createStatement();
        statement.execute("drop table Greetings");
        int update = statement.executeUpdate("CREATE TABLE Greetings (Message CHAR(40))");
        statement.executeUpdate("INSERT INTO Greetings VALUES('hello')");
        System.out.println(update);
        ResultSet resultSet = statement.executeQuery("select * from Greetings");
        while(resultSet.next()){
            System.out.println(resultSet.getString("Message"));
        }

    }
}